package com.demo.employees.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo.employees.dao.EmployeeRepository;
import com.demo.employees.model.Employee;
import com.demo.employees.service.EmployeeService;

@Service(value="EmployeeServiceDataJpaImpl")
public class EmployeeServiceDataJpaImpl implements EmployeeService {
	
	@Autowired
	private EmployeeRepository employeeRepository;

	@Override
	public void saveEmployee(Employee employee) {
		employeeRepository.save(employee);
	}

	@Override
	public void updateEmployee(Employee employee) {
		employeeRepository.save(employee);
	}

	@Override
	public Employee getById(Long id) {
		return employeeRepository.findOne(id);
	}

	@Override
	public List<Employee> findAll() {
		return employeeRepository.findAll();
	}

	@Override
	public int getCount() {
		return (int)employeeRepository.count();
	}

	@Override
	public void deleteById(Long id) {
		employeeRepository.delete(id);
	}

}
